#include "OCMain/StringUtil.h"

#define _FFIExport extern "C" __declspec(dllexport)

namespace OCPP
{
	_FFIExport int add(int a, int b)
	{
		return a + b;
	}

	struct FFIData
	{
		void* data = nullptr;
		size_t size = 0;
	};

	_FFIExport FFIData ffi_getData(const char* options)
	{
		std::cout << options << std::endl;
		printf("delete []\n");
		std::cout << "Hello from C++\n" << std::flush;
		String s = "hello world.";
		s += options;
		size_t size = s.size();
		FFIData ffiData;
		ffiData.data = new uint8_t[size];
		memcpy(ffiData.data, s.data(), size);
		ffiData.size = size;
		return ffiData;
	}

	_FFIExport void ffi_freeArray(void* data)
	{
		if (data) {
			delete[] static_cast<char*>(data);
		}
	}

	_FFIExport void ffi_freeObject(void* data)
	{
		if (data) {
			delete data;
		}
	}
}

